#include "showsignature.h"
#include "ui_showsignature.h"

//显示签名
ShowSignature::ShowSignature(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ShowSignature)
{
    ui->setupUi(this);

//    this->setParent(parent);
    this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明
    this->setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint);
    //    QString str("QWidget{background-color:rgba(51,51,51,0.4);}");
//    this->setStyleSheet(str);
}

ShowSignature::~ShowSignature()
{
    delete ui;
}

void ShowSignature::shsize(int x, int y, int w, int h)
{
    this->setGeometry(x, y+32, w, h);
    ui->pushButton->setGeometry(0, 0, w, h);
    ui->label_2->setGeometry(0, 0, w, h);
}

void ShowSignature::setPixmap(QString path)
{
    QImage image;
    image.load(path);

    int width = image.width();
    int height = image.height();

    ui->label->setPixmap(QPixmap::fromImage(image));
    ui->label->resize(QSize(width,height));

//    QPoint globalPos = this->mapToGlobal(QPoint(0,0));//父窗口绝对坐标
    int x =(this->width() - ui->label->width()) / 2 + 150;//x坐标
    int y =(this->height() - ui->label->height()) / 2 + 40;//y坐标
    ui->label->move(x, y);//移动标签，使其居中对齐
}

void ShowSignature::setPixmap(QPixmap image)
{
    int width = image.width();
    int height = image.height();

    ui->label->setPixmap(image);
    ui->label->resize(QSize(width,height));

//    QPoint globalPos = this->mapToGlobal(QPoint(0,0));//父窗口绝对坐标
    int x =(this->width() - ui->label->width()) / 2 + 150;//x坐标
    int y =(this->height() - ui->label->height()) / 2 + 40;//y坐标
    ui->label->move(x, y);//移动标签，使其居中对齐
}

void ShowSignature::on_pushButton_clicked()
{
    delete this;
}
